1. Field of the Invention
An existing oscillator circuit adjusts an oscillation frequency of the oscillator circuit by externally installing resistors and capacitors outside an integrated circuit encapsulating the oscillator circuit. Although the method of employing the externally installed resistors and capacitors to adjust the oscillation frequency can obtain oscillation frequency with a high degree of accuracy, the external installment of the resistors and capacitors will increase pins encapsulated in the integrated circuit, an area of the oscillator circuit, and a cost of the resistors and capacitors, so that the cost of the whole oscillator circuit increases.
2. Description of the Related Art
FIG. 1 is a view illustrating a conventional circuit for providing a clock to a chip 10 by using an external crystal CR. The circuit generates a clock for the chip 10 by using the externally connected external crystal CR and load capacitors C1 and C2, and an internal crystal driver circuit integrated in the chip 10.
Since the circuit illustrated in FIG. 1 uses a conventional crystal circuit to provide a clock for the chip 10, a separated crystal CR and external load capacitors C1 and C2 are necessary, and the cost increases. In addition, since two pins of the chip are occupied to externally connect the crystal circuit, the circuit illustrated in FIG. 1 is not adaptive to chips having few pins, which limits the scope of applications to which the circuit may be applied.
FIG. 2 illustrates an internal oscillator circuit 20, the oscillation frequency of which can be adjusted, and the internal oscillator circuit 20 generates a clock required by a chip by using a frequency control circuit 22 and an internal oscillator 24. The frequency control circuit 22 is used to generate control bits for the internal oscillator 24, and the internal oscillator 24 is used to generate different output frequencies according to different control bits. In order to obtain a required frequency, all of the bits can be scanned so as to obtain control bits which are close to a target frequency.
Although the circuit illustrated in FIG. 2 can control the frequency of the internal oscillator by using the frequency control circuit, times of scanning operations may be 2N (N indicates a number of the control bits of the internal oscillator), so as to obtain an optimal result. Since time for scanning is so long, and numbers of control bits of different chips may be completely different from each other, the circuit illustrated in FIG. 2 is may not be able to be fixed or corrected after the circuit has been produced or manufactured.
FIG. 3A illustrates an internal oscillator circuit 30, the oscillation frequency of which can be auto-adjusted, and the internal oscillator circuit includes a frequency comparer 32, a Successive-Approximation-Register (SAR) comparer 34, and an internal oscillator 36. The frequency comparer 32 compares the current oscillation frequency of the internal oscillator circuit with a target frequency, and outputs a comparing result to the SAR comparer 34. The SAR comparer 34 determines to set a corresponding bit to 0 or 1 according to the comparing result.
FIG. 3B is a flowchart illustrating a method corresponding to the internal oscillator circuit, the oscillation frequency of which can be auto-adjusted. In operation 41, a selected bit K is set at N−1, where N−1 corresponds to a highest level bit of a plurality of bits. For example, if three control bits are used, then the highest level bit is N−1, the next level bit is N−2, and the lowest level bit is N−3. In operation 42 all the bits are set to 0. In operation 43, the Kth bit is set to 1. Consequently, the internal oscillator 36 generates a predetermined frequency (corresponding to the control bits 100, for example). In operation 44, the generated frequency Fosc is compared with a reference frequency Fref. If the generated frequency Fosc is greater than the reference frequency Fref, then the Kth bit is set to 0 (command bits are 000) in operation 46. Otherwise, the Kth bit is maintained at 1 in operation 45.
In operation 47, the Kth bit is set to K−1. In other words, the next lowest level bit is selected. In operation 48, it is determined whether K is less than 0, or if the last bit to be analyzed was the lowest level bit. If not, then the Kth bit is set to 1 (command bits may be set to 110 or 010, depending on outcome of previous analysis) and operations 43-48 are repeated. This operation is repeated until the value of the 0th bit, or lowest-level bit, is determined.
An internal oscillator having 3 control bits will be provided as an example by referring to the following Table 1, which illustrates a corresponding relationship between frequencies of the internal oscillator and control bits of the internal oscillator.
TABLE 1Control bits3′b0003′b0013′b0103′b0113′b1003′b1013′b1103′b111frequencies6.4M6.9M7.4M7.8M8.1M8.5M9.0M9.6M
Assuming that the frequency of a reference signal (hereinafter, referred to as the reference frequency) is same as a target frequency, both of the frequency of the reference signal and the target frequency may be 8 MHz. The method illustrated in FIG. 3B performs the following operations.
First, in operation 41, the greatest-level bit, or the second bit is selected as the Kth bit. Next, in operation 42, all the bits are set to 0. Then, in operation 43, the second bit of the control bits is set to 1. The value of the corresponding control bits is 3′b100, which corresponds to a frequency of 8.1 MHz. In operation 44 it is determined whether the generated frequency, 8.1 MHz, is greater than the target frequency, 8 MHz. Since the generated frequency is greater than the target frequency, in operation 46 the second bit is set again to 0, and the value of corresponding control bits at this time is 3′b000.
Next, in operation 47, the first bit of the control bits is set as the Kth bit. In operation 48 it is determined that 1 is not less than 0, and in operation 43 the first bit of the control bits is set to 1, and the value of corresponding control bits is 3′b010. Since the frequency corresponding to the value 3′b010 of the control bits is 7.4 MHz, then it is determined in operation 44 that the oscillation frequency of the internal oscillator is less than the target frequency. In operation 45, the first bit of the control bits is maintained at 1, and the value of corresponding control bits at this time is 3′b010.
In operation 47, the 0th bit of the control bits is selected, and in operation 48 it is determined that 0 is not less than 0. In operation 43, the 0th bit of the control bits is set to 1, and at this time the value of corresponding control bits is 3′b011, which corresponds to a frequency of 7.8 MHz. In operation 44 it is determined that the oscillation frequency of the internal oscillator is less than the target frequency, so in operation 45 the 0th bit of the control bits is maintained at 1, and the value of corresponding control bits at this time is 3′b011.
In operation 47, K is set to −1, and in operation 48 it is determined that −1 is less than 0, so the comparison of the 0th bit of the control bits is finished. The value of the finally auto-trimmed control bits is 3′b011, and the auto-trimmed frequency is 7.8 MHz.
The internal oscillator circuit illustrated in FIG. 3A can auto-trim frequencies, and the number of times of the scanning is only N (N indicates a number of the control bits of the internal oscillator). However, as illustrated above, the finally auto-trimmed frequency is 7.8 MHz. However, the frequency of 8.1 MHz is closer to the target frequency than the final frequency of 7.8 MHz. Therefore, the result obtained by using the method may not be the optimal result.
In order to save cost of design, more and more designs employ an internal oscillator, rather than an external clock circuit, to provide clocks. It is difficult to make internal oscillator frequencies of each chip to be identical due to differences of semiconductor manufacturing processes. In order to reduce the differences among chips, the internal oscillator frequencies are set to be available for adjusting. The internal oscillator frequencies are made to be approximately same with each other by setting the control bits of the internal oscillators.